<?php namespace Admin\Controller;
use Hdphp\Controller\Controller;
/**
* 品牌控制器
*/
class BrandController extends CommonController{
	private $model;
	public function __init()
	{
		parent::__init();
		$this->model=new \Common\Model\Brand;
	}
	public function index()
	{
		$data=$this->model->get();
		View::with('data',$data);
		View::make();
	}
	public function add()
	{
		if (IS_POST) {
			if (!$this->model->store()) {
				View::error($this->model->getError());
			}
			View::success('添加成功',U('index'));
		}
		View::make();
	}
	public function edit()
 	{
 		$bid=Q('get.bid',0,'intval');
 		if (IS_POST) {
 			if(!$this->model->edit($bid)) View::error($this->model->getError());
 			Cache::flush();
 			View::success('修改成功',U('index'));
 		}
 		$oldData=$this->model->where("bid={$bid}")->find();
 		View::with('oldData',$oldData);
 		View::make();
 	}
	public function del()
	{
		$bid=Q('get.bid',0,'intval');
 		$this->model->delete($bid);
 		View::success('删除成功');
	}
}

 ?>